package com.example.jdimust.ledger;

/**
 * Author: MaZongyang
 * Date: 2021/5/18/0018 23:49
 * Description:
 */

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.jdimust.R;
import com.example.jdimust.ledger.LedMes;

import java.util.List;

public class LedMesAdapter extends ArrayAdapter<LedMes> {
    private int resourceId;

    public LedMesAdapter(Context context, int textViewResourceId, List<LedMes> objects) {

        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        LedMes ledmes = getItem(position);
        @SuppressLint("ViewHolder")
        View view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        TextView ledname = (TextView) view.findViewById(R.id.ledmes_lv_ledname);
        TextView ledhash = (TextView) view.findViewById(R.id.ledmes_lv_ledhash);
        TextView ledid = (TextView) view.findViewById(R.id.ledmes_lv_ledid);
        TextView ledsta = (TextView) view.findViewById(R.id.ledmes_lv_ledsta);
        ledname.setText(ledmes.getledgerName());
        ledhash.setText(ledmes.getLedgerHash());
        ledid.setText(ledmes.getLedgerUid());
        ledsta.setText(ledmes.getState());
        return view;

    }
}
